using System.Configuration;
using System.Data;
using MySqlConnector;

namespace way.util
{
    public static class DatabaseUtil
    {
        public static string database= ConfigurationManager.AppSettings["database"];
        public static string connectionParameter= ConfigurationManager.AppSettings["databaseServer"];
        public static bool checkTableExist(string dbName,string tableName)
        {
            //bool flag = false;
            //if (string.IsNullOrWhiteSpace(dbName)) return flag;
            //if (string.IsNullOrWhiteSpace(tableName)) return flag;
            //string checkSql = @"
            //    select count(*) from information_schema.tables
            //    where table_schema=@DbName and table_name=@TableName";
            //using (var connection=new MySqlConnection(connectionParameter))
            //{
            //    connection.Open();
            //    int tableCount = connection.ExecuteScalar<int>(
            //        sql: checkSql,
            //        param: new { DbName = dbName, TableName = tableName },
            //        commandType: CommandType.Text);
            //    flag= tableCount > 0;
            //}
            //return flag;
            throw new Exception();
        }
        public static string getDatabase() {
            connectionParameter= ConfigurationManager.AppSettings["databaseServer"];
            return connectionParameter;
        }
    }
}
